<?php

class HomeController extends \BaseController {

	/**
	 * Display a listing of the resource.
	 *
	 * @return Response
	 */
	public function index()
	{   
		//LẤY DANH SÁCH MÔN HỌC
		$monHoc = MonHoc::where('TRANG_THAI', '=', 1)
		->whereNull('PARENT_ID')
		->orderBy('THU_TU', 'DESC')->get();
		//LẤY DANH SÁCH CHƯƠNG
		$chuong = MonHoc::where('TRANG_THAI', '=', 1)
		->whereNotNull('PARENT_ID')->orderBy('THU_TU')->get();
		return View::make("home")->with('mon_hoc',$monHoc)->with('chuongs',$chuong);
	}

	public static function ktDangNhap()
    {    	
		 if (Session::has('logined')){
	  		return true;
	  	 }
	  	else{
	  		return false;
	  	}
    }
	/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
	public function create()
	{
		//

	}


	/**
	 * Store a newly created resource in storage.
	 *
	 * @return Response
	 */
	public function store()
	{
		//
	}


	/**
	 * Display the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function show($alias)
	{
		$ghi_chu = GhiCHuMonHoc::where('TRANG_THAI', '=', 1)->where('ALIAS','=',$alias)->first();
		return View::make("article")->with('ghi_chu',$ghi_chu); //echo "Hiễn thị bài ".$id;
	}


	/**
	 * Show the form for editing the specified resource.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function edit($id)
	{
		//
	}


	/**
	 * Update the specified resource in storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function update($id)
	{
		//
	}


	/**
	 * Remove the specified resource from storage.
	 *
	 * @param  int  $id
	 * @return Response
	 */
	public function destroy($id)
	{
		//
	}


}
